/*
 * @Author: 颜礼田 yanlitian@carleagroup.com
 * @Date: 2024-08-13 14:20:57
 * @LastEditors: 颜礼田 2564217790@qq.com
 * @LastEditTime: 2024-09-07 10:52:53
 * @FilePath: \server\src\filter\unauthorized.filter.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Catch, httpError, MidwayHttpError } from '@midwayjs/core';
import { useUnauthorized } from '../utils/resHelper';
import { Context } from '@midwayjs/koa';

@Catch(httpError.UnauthorizedError)
export class UnauthorizedFilter {
  async catch(err: MidwayHttpError, ctx: Context) {
    ctx.logger.warn(err);
    return useUnauthorized(err.message);
  }
}
